package controllers.validation;

import java.util.List;

import models.SensorConfig;
import models.SensorData;
import models.UserConfig;

import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;

import controllers.validation.ValidationJob;
import ch.bfh.abcm.rems.gateway.GateWayMessageType;
import ch.bfh.abcm.rems.gateway.GatewayMessage;
import ch.bfh.abcm.rems.sensors.tinkerforge.TFSensorType;

public class EffectiveValueAndSystemOkay extends AbstractValidationTest {

    @Test
    public void testEffectiveValueAndSystemOkayTemperature() throws InterruptedException {
        insertCorrectTempLuxHumSensorData(5);
        insertCorrectNodeAverages(5);
        new ValidationJob(HOST_IP_TEMPERATURE).now();
        Thread.sleep(WAIT_FOR_RECEIVING);
        GatewayMessage message = receiverimplemntation.getGatewayMessage();
        System.out.println(message);
        Assert.assertNull(receiverimplemntation.getUpdateSensorConfigMessage());
        Assert.assertNull(receiverimplemntation.getUpdateUserConfigMessage());
        Assert.assertEquals(GateWayMessageType.SYSTEM_ERROR, message.getMessageType());
        Assert.assertEquals("ok", message.getMessage());
    }
    
    @Test
    public void testEffectiveValueAndSystemOkayAmbient() throws InterruptedException {
        insertCorrectTempLuxHumSensorData(5);
        insertCorrectNodeAverages(5);
        new ValidationJob(HOST_IP_AMBIENT).now();
        Thread.sleep(WAIT_FOR_RECEIVING);
        GatewayMessage message = receiverimplemntation.getGatewayMessage();
        System.out.println(message);
        Assert.assertNull(receiverimplemntation.getUpdateSensorConfigMessage());
        Assert.assertNull(receiverimplemntation.getUpdateUserConfigMessage());
        Assert.assertEquals(GateWayMessageType.SYSTEM_ERROR, message.getMessageType());
        Assert.assertEquals("ok", message.getMessage());
    }
    
    @Test
    public void testEffectiveValueAndSystemOkayHumidity() throws InterruptedException {
        insertCorrectTempLuxHumSensorData(5);
        insertCorrectNodeAverages(5);
        new ValidationJob(HOST_IP_HUMIDITY).now();
        Thread.sleep(WAIT_FOR_RECEIVING);
        GatewayMessage message = receiverimplemntation.getGatewayMessage();
        System.out.println(message);
        Assert.assertNull(receiverimplemntation.getUpdateSensorConfigMessage());
        Assert.assertNull(receiverimplemntation.getUpdateUserConfigMessage());
        Assert.assertEquals(GateWayMessageType.SYSTEM_ERROR, message.getMessageType());
        Assert.assertEquals("ok", message.getMessage());
    }
}